package dyyx.agent.attach;
import com.sun.tools.attach.VirtualMachine;

public class MyAttachTest {

	public static void main(String[] args) throws Exception {
		
		if(args==null || args.length!=2){
			System.out.println("args error,need pid and agentpath");
			return;
		}

		String pid = args[0];
		String agent = args[1];
		
		System.out.println("pid="+pid);
		System.out.println("agent="+agent);

		
	    VirtualMachine vm = VirtualMachine.attach(pid);
	    
		System.out.println("vm="+vm);

	    
	    vm.loadAgent(agent);
	    
	    vm.detach();
	          
	          
	}
}
